package com.homeWork05;

public class Produce extends Thread {
    public static int stork = 10;
    private Lock lock;
    public Produce(Lock lock){
        this.lock=lock;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (lock) {
                if (stork < 0 || stork > 10) {
                    break;
                }
                stork++;
                System.out.println("生产存入1个单位货物，现在仓库剩余" + stork);
            }
        }
    }
}
